#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define all(x) (x).begin(),(x).end()
typedef long long ll;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<VI> VVI;

typedef pair<int,int> PII;
typedef vector<PII> VPII;
#define X first
#define Y second
#define mp make_pair

#define two(x) (1<<(x))
#define twoll(x) ((long long)1<<(x))
#define contain(s,x) (((s)&two(x))!=0)
#define containll(s,x) (((s)&twoll(x))!=0)

#define db(a) cout << #a << "=" << a << " "
#define dbn cout << endl
#define sqr(x) (x)*(x)

string STR(int n) { char tmp[20]; sprintf(tmp,"%d",n); return tmp; }
int INT(string s) { return atoi(s.c_str()); }
template <class Ty, class Tx> Ty to(const Tx &x) { Ty y; stringstream ss; ss<<x; ss>>y; return y; }

const int INF = 1000000007;
const double EPS = 1e-10;

char buf[1<<20];
int TC;

char O[10][10];
int N,R[10];

bool check(int v, char c) {
	if (c == '+' && v <= 0
			|| c == '-' && v >= 0
			|| c == '0' && v != 0
			)
		return 0;
	return 1;
}

void go(int idx, int val) {
	static bool f = 0;
	if (f)
		return;
	R[idx] = val;
	int acc = val;
	for (int i = idx-1; i >= 0; --i) {
		acc += R[i];
		if (!check(acc,O[i][idx]))
			return;
	}
	
	if (idx == N-1) {
		f = 1;
		return;
	}
	
	if (O[idx+1][idx+1] == '+')
		for (int i = 1; i <= 10; ++i)
			go(idx+1,i);
	else if (O[idx+1][idx+1] == '-')
		for (int i = -10; i <= -1; ++i)
			go(idx+1,i);
	else
		go(idx+1,0);
}

int main() {
#define SUBMIT 0
#if !SUBMIT
	freopen("DATA.in", "rt", stdin);
	freopen("DATA.ou", "wt", stdout);
#endif

	gets(buf); TC = atoi(buf);
	
	while (TC--) {
		gets(buf); N = atoi(buf);
		gets(buf);
		int idx = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = i; j < N; ++j) {
				O[i][j] = buf[idx++];
			}
		}
		
		go->f = 0;
		
		if (O[0][0] == '+')
			for (int i = 1; i <= 10; ++i)
				go(0,i);
		else if (O[0][0] == '-')
			for (int i = -10; i <= -1; ++i)
				go(0,i);
		else
			go(0,0);
		
		for (int i = 0; i < N; ++i)
			printf("%d ",R[i]);
		printf("\n");
	}

	return 0;
}





